<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>6.Promise的基本使用</title>
    </head>
    <body>
        <!-- 
            三种状态：
                1.pending 初始化
                2.fulfilled 成功的
                3.rejected 失败的
            两种改变
                调用resolve即可完成：pending => fulfilled
                调用reject即可完成：pending => rejected
            两个回调
                .then(成功的回调,失败的回调)
                .catch(失败的回调)
         -->
        <script type="text/javascript" >
            let p = new Promise((resolve,reject)=>{
                // resolve(666)
                // reject(777)
                // console.log(a)
                // throw '你个该死的'
            })
            /* p.then(
                (value)=>{console.log('p成功了',value)},
                (reason)=>{console.log('p失败了',reason)}
            ) */
            p.catch(
                (reason)=>{console.log('p失败了',reason)}
            )
        </script>
    </body>
</html>